package com.yh.mapper;

import com.yh.pojo.Product;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * @author by 张晨光
 * @date 2024/1/24 10:11
 */
public interface ProductMapper {
    @Select("select * from product")
    List<Product>findAll();
    @Insert("INSERT INTO product ( `productNum`, `productName`, `cityName`, `departureTime`, `productPrice`, `productDesc`, `productStatus`) \n" +
            "VALUES ( #{productNum},#{productName},#{cityName},#{departureTime},#{productPrice},#{productDesc},#{productStatus});")
    void save(Product product);

    @Select("select  * from product where id=#{id}")
    Product findById(Integer id);
    @Update("update  product set productNum=#{productNum},productName=#{productName},cityName=#{cityName},departureTime=#{departureTime},productPrice=#{productPrice},productDesc=#{productDesc},productStatus=#{productStatus}" +
            "where id=#{id}")
    Product update(Product product);
    @Delete("delete from product where id=#{id}")
    void delete(Integer id);
}
